package com.wang.spring.basic_dl.d_withannotation;

import com.wang.spring.basic_dl.d_withannotation.anno.Color;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Map;
import java.util.stream.Stream;

/**
 * @author wangchao05
 */
public class WithAnnoApplication {
    public static void main(String[] args) {

        ApplicationContext context = new ClassPathXmlApplicationContext("basic_dl/quickstart-withanno.xml");
        // 这个方法就是讲所有 类上面都标注了 @Color 的bean都找出来
        Map<String, Object> beansWithAnnotation = context.getBeansWithAnnotation(Color.class);
        beansWithAnnotation.forEach((beanName, bean) -> {
            System.out.println(beanName+"===="+bean.toString());
        });

        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        Stream.of(beanDefinitionNames).forEach(System.out::println);
        Stream.of(beanDefinitionNames).forEach(name-> System.out.println(context.getBean(name)));


    }
}
